package com.lanou.renrenxin.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.lanou.renrenxin.R;
import com.lanou.renrenxin.base.BaseActivity;


/**
 * Created by zy on 16/3/9.
 * 新建群组
 */
public class NewGroupActivity extends BaseActivity implements View.OnClickListener {
    //群组名称,群组简介
    private EditText groupNameEditext,introductionEditText;
    private Button btnBack,btnCreat;
    private TextView textViewTitle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_newgroup);
        initView();
        setup();
    }

    private void initView() {
        groupNameEditext = (EditText) findViewById(R.id.edit_group_name);
        introductionEditText = (EditText) findViewById(R.id.edit_group_introduction);
        btnBack = (Button) findViewById(R.id.btnBack);
        textViewTitle = (TextView) findViewById(R.id.txtTitle);
        btnCreat = (Button) findViewById(R.id.btnCreat);
    }

    private void setup() {
        btnBack.setVisibility(View.VISIBLE);
        btnCreat.setVisibility(View.GONE);
        btnBack.setOnClickListener(this);
        textViewTitle.setText("新建群组");
    }

    //保存按钮点击事件,在布局中定义
    public void save(View v){
        String groupName = groupNameEditext.getText().toString();
        String groupIntroduce = introductionEditText.getText().toString();
        if (TextUtils.isEmpty(groupName)){
            BaseActivity.ShowToast("请输入群组名称");
        }else {
            //选取拉入群组的人
            Intent intent = new Intent(this,PickGroupContactActivity.class);
            intent.putExtra("groupname",groupName);
            intent.putExtra("groupintroduce",groupIntroduce);
            startActivity(intent);
            finish();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btnBack:
                finish();
                break;
        }
    }
}
